package de.hhbk.feedbackmodul.entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the frage database table.
 * 
 */
@Entity
@Table(name="frage")
public class Question implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int id;

	@Column(length=255)
	private String text;

	@Column(length=30)
	private String typ;
	
	//bi-directional many-to-one association to Antwort
	@OneToMany(mappedBy="frage")
	private Set<Answer> antworts = new HashSet<Answer>();

	//bi-directional many-to-one association to User
    @ManyToOne
	@JoinColumn(name="fk_user")
	private User user;

    @ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "fragebogen_frage", joinColumns = { 
			@JoinColumn(name = "fk_frage", nullable = false, updatable = false,unique=true) }, 
			inverseJoinColumns = { @JoinColumn(name = "fk_fragebogen", 
					nullable = false, updatable = false,unique=true) })
    private Set<QuestionSheet> frageboegen = new HashSet<QuestionSheet>();
    
    @ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "frage_antwortmoeglichkeit", joinColumns = { 
			@JoinColumn(name = "fk_frage", nullable = false, updatable = false,unique=true) }, 
			inverseJoinColumns = { @JoinColumn(name = "fk_antwortmoeglichkeit", 
					nullable = false, updatable = false,unique=true) })
    private Set<AnswerPossibility> antwortmoeglichkeiten = new HashSet<AnswerPossibility>();
    
    public Question() {
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}
	
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getTyp() {
		return typ;
	}

	public void setTyp(String typ) {
		this.typ = typ;
	}

	public Set<Answer> getAntworts() {
		return antworts;
	}

	public void setAntworts(Set<Answer> antworts) {
		this.antworts = antworts;
	}

	public Set<QuestionSheet> getFrageboegen() {
		return frageboegen;
	}

	public void setFrageboegen(Set<QuestionSheet> frageboegen) {
		this.frageboegen = frageboegen;
	}

	public Set<AnswerPossibility> getAntwortmoeglichkeiten() {
		return antwortmoeglichkeiten;
	}

	public void setAntwortmoeglichkeiten(
			Set<AnswerPossibility> antwortmoeglichkeiten) {
		this.antwortmoeglichkeiten = antwortmoeglichkeiten;
	}
	
}